home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Run & Stumpy / source / rawdrive.cp < prev    next >
Encoding:
Text File  |  1992-06-19  |  1.2 KB  |  59 lines  |  [TEXT/MPS ]

  1. #include <files.h>
  2. #include "rawdrive.h"
  3.  
  4. rawdrive::rawdrive( const FSSpec& volume )
  5.   {
  6.     HParamBlockRec pb;
  7.     
  8.     pb.volumeParam.ioCompletion= 0;
  9.     pb.volumeParam.ioNamePtr= 0;
  10.     pb.volumeParam.ioVRefNum= volume.vRefNum;
  11.     pb.volumeParam.ioVolIndex= -1;
  12.     error = PBHGetVInfo( &pb, 0 );
  13.     
  14.     drive=  pb.volumeParam.ioVDrvInfo;
  15.     driver= pb.volumeParam.ioVDRefNum;
  16.   }
  17.  
  18. OSErr rawdrive::read( long position, void *buffer, uint32& amount )
  19.   {
  20.     if (iswrong())
  21.         return whatiswrong();
  22.     
  23.     ParamBlockRec pb;
  24.     pb.ioParam.ioCompletion= 0;
  25.     pb.ioParam.ioVRefNum= drive;
  26.     pb.ioParam.ioRefNum= driver;
  27.     pb.ioParam.ioBuffer= (Ptr)buffer;
  28.     pb.ioParam.ioReqCount= amount;
  29.     pb.ioParam.ioPosMode= fsFromStart;
  30.     pb.ioParam.ioPosOffset= position;
  31.     
  32.     OSErr readerror= PBReadSync(&pb);
  33.     
  34.     amount= pb.ioParam.ioActCount;
  35.     
  36.     return readerror;
  37.   }
  38.  
  39. OSErr rawdrive::write( long position, void *buffer, uint32& amount )
  40.   {
  41.     if (iswrong())
  42.         return whatiswrong();
  43.     
  44.     ParamBlockRec pb;
  45.     pb.ioParam.ioCompletion= 0;
  46.     pb.ioParam.ioVRefNum= drive;
  47.     pb.ioParam.ioRefNum= driver;
  48.     pb.ioParam.ioBuffer= (Ptr)buffer;
  49.     pb.ioParam.ioReqCount= amount;
  50.     pb.ioParam.ioPosMode= fsFromStart;
  51.     pb.ioParam.ioPosOffset= position;
  52.     
  53.     OSErr writeerror= PBWriteSync(&pb);
  54.     
  55.     amount= pb.ioParam.ioActCount;
  56.     
  57.     return writeerror;
  58.   }
  59.